import 'package:flutter/material.dart';
import 'package:flutter_blog_manage_study/app/app_theme.dart';
import 'package:flutter_blog_manage_study/res/strings.dart';
import 'package:flutter_blog_manage_study/routes/routes.dart';
import 'package:flutter_blog_manage_study/ui/page/splash/splash_binding.dart';
import 'package:flutter_blog_manage_study/ui/page/splash/splash_page.dart';
import 'package:flutter_blog_manage_study/util/injection_init.dart';
import 'package:flutter_blog_manage_study/util/keyboard_util.dart';
import 'package:flutter_blog_manage_study/util/local_util.dart';
import 'package:get/get.dart';

/// * 作者: Tao
/// * 日期: 2024/3/20
/// * 时间: 16:16
/// * 描述: 程序入口
void main() async{
  // 初始化各种binding，如GestureBinding、ServicesBinding等，在一些深度定制的场景下可能会用到
  WidgetsFlutterBinding.ensureInitialized();
  // 异步初始化依赖注入，主要是初始化SharedPreferences和RequestRepository
  await Injection.init();
  // 这里使用GetMaterialApp，而不是MaterialApp，GetMaterialApp是GetX框架的MaterialApp的封装
  runApp(GetMaterialApp(
    getPages: Routes.routePage, //路由配置
    debugShowCheckedModeBanner: false, //是否显示右上角的debug标签
    initialRoute: '/', //初始路由
    builder: (context, child) => Scaffold(
      // Global GestureDetector that will dismiss the keyboard
      body: GestureDetector(
        onTap: () {
          // 点击空白处隐藏键盘
          KeyboardUtil.hideKeyboard(context);
        },
        child: child,
      ),
    ),
    theme: appThemeData, //主题颜色
    defaultTransition: Transition.fade, //页面切换动画
    translations: Messages(), //国际化支持-来源配置
    locale: LocalUtil.getDefaultLanguage(), //国际化支持-默认语言
    fallbackLocale: const Locale('en', 'US'), //国际化支持-备用语言
    initialBinding: SplashBinding(), //初始化绑定
    home: const SplashPage(), //启动页
  ));
}
